<template>
  <el-pagination
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :current-page="pagenum"
    :page-sizes="pageSizesArr"
    :page-size="pagesize"
    :total="total"
    background
    :layout="layout"
  >
  </el-pagination>
</template>

<script>
export default {
  name: 'Mypagination',
  props: {
    pagenum: {
      type: Number,
      default: 1
    },
    pagesize: {
      type: Number,
      default: 5
    },
    total: {
      type: Number,
      default: 0
    },
    pageSizesArr: {
      type: Array,
      default () {
        return [5, 10, 15, 20];
      }
    },
    layout: {
      type: String,
      default: "total, sizes, prev, pager, next, jumper"
    }
  },
  data () {
    return {
      page: {
        _pageSize: this.pagesize,
        _currentPage: this.pagenum
      },
    }
  },
  methods: {
    handleSizeChange (newSize) {
      this.page._pageSize = newSize
      this.$emit('pageChange', this.page)
    },
    handleCurrentChange (newPage) {
      this.page._currentPage = newPage
      this.$emit('pageChange', this.page)
    }
  },
}
</script>

<style>
</style>